package top.lww0511.extra.config;

import com.baomidou.mybatisplus.core.MybatisConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import top.lww0511.extra.interceptor.Many2ManyInterceptor;
import top.lww0511.extra.interceptor.One2ManyInterceptor;
import top.lww0511.extra.interceptor.One2OneInterceptor;
import top.lww0511.extra.interceptor.PrintSqlInterceptor;

/**
 * Mybatis Plus Config
 *
 * @author lww
 */
@Configuration
@ComponentScan(basePackages = "top.lww0511.extra")
public class MybatisExtraConfig {

    @Bean
    public MybatisConfiguration getMybatisConfiguration() {
        MybatisConfiguration configuration = new MybatisConfiguration();
        //打印sql
        configuration.addInterceptor(new One2OneInterceptor());
        configuration.addInterceptor(new One2ManyInterceptor());
        configuration.addInterceptor(new Many2ManyInterceptor());
        configuration.addInterceptor(new PrintSqlInterceptor());
        return configuration;
    }

}